<template>
	<view>
		<view v-if="!realshow">
		<view style="text-align: center;" class="title">支付宝账号</view>
	    <view style="width:100%;text-align: center;">温馨提示</view>
		<view style="margin:0 15upx;font-size:30upx;color:#464646">请正确输入支付宝帐号，姓名进行保存，卡密码验证成功后，自动转入您保存的帐号</view>
		<view class="name">
			<view class="headline">真实姓名:</view>
			<input type="text" v-model="name" placeholder="请输入您的真实姓名" />
		</view>
		<view class="number">
			<view class="headline">支付宝账号:</view>
			<input type="text" v-model="phone" placeholder="请输入您的支付宝账号" />
		</view>
		<view class="number">
			<view class="headline">身份证号码:</view>
			<input type="text" v-model="card" placeholder="请输入您的身份证号码" />
		</view>
		<!-- <view class="number">
			<view class="headline">手机号码:</view>
			<input type="text" v-model="mobile" placeholder="请输入您的手机号码" />
		</view>
		<view class="number">
			<view class="headline">验证码:</view>
			<input type="text" v-model="captcha" placeholder="请输入您的验证码" />
			<button class="mini-btn" type="primary" size="mini">获取验证码</button>
		</view> -->
		<view class="btn">
			<button @click="commit">提交账号</button>
		</view>
		</view>
		
		<view v-else >
			<view style="margin-left:50upx;margin-top:50upx;">姓名：{{name}}</view>
			<view class="zh">
			 <text>支付宝账户:</text>
			 <view @tap="showsubmit">
				<!--  <view>
					 <image style="width: 30upx;height:30upx;" src="../../static/images/dxx.png"></image> 
					 <text>支付宝</text>
				  </view> -->
                   <text style="padding-left:15upx;">{{phone}}</text>
			 </view> 
			 </view>
			 <view class="zh">
				 <text>身份证号:</text>
				 <view>
					 <text style="padding-left:15upx;">{{card}}</text>
				 </view>
			 </view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:'',
				phone:'',
				card:'', //身份证号码
				mobile: '',
				captcha: '',
				realshow:false,
				token:'',//onShow时获取token存起来，以便每次发送请求都要重新获取
				current:''
			}
		},
		onLoad(options) {
			if(options.current){
				this.current=options.current
			}else{
				console.log('不是从提交卡页面过来的')
			}
			
		},
		onShow(){
			if(this.type_==2){
				AlipayJSBridge.call('setTitle', {
				      title: '专注卡券回收服务—卖卡啦'
				    });
			}
            this.getrealdata()
		},
		methods: {
			showsubmit(){
				this.realshow=false;
			},
			getrealdata(){
				this.token = uni.getStorageSync('token')
				uni.request({
					url: this.url + '/mobile/realData',
					method:'GET',
					header: {
						'content-type': 'application/x-www-form-urlencoded' ,// 默认值
						'token': this.token
					},
					data:{
						
					},
					success: (res) => {
						if(res.data.alipayAccount !='' && res.data.alipayAccount !='null'  && res.data.realName!='null' && res.data.realName!=''){
							this.realshow = true;
							this.name = res.data.realName;
							this.phone=res.data.alipayAccount;
							this.card=res.data.IDCardNumber == 'null' ? '' : res.data.IDCardNumber
						}else{
						    this.realshow = false;
						}
					}
				})
			},
			commit(){
				let that=this;
				if(this.name == '') {
					uni.showModal({
					    title: '提示',
					    content: '用户名不能为空',
					});
					return false
				}else if(this.phone == '') {
					uni.showModal({
					    title: '提示',
					    content: '支付宝账号不能为空',
					});
					return false
				} else if(this.card == '') {
					uni.showModal({
					    title: '提示',
					    content: '身份证号码不能为空',
					});
					return false
				} 
				// else if(this.mobile == '') {
				// 	uni.showModal({
				// 	    title: '提示',
				// 	    content: '手机号码不能为空',
				// 	});
				// 	return false
				// } else if(this.captcha == '') {
				// 	uni.showModal({
				// 	    title: '提示',
				// 	    content: '验证码不能为空',
				// 	});
				// 	return false
				// }
				else {
					uni.request({
						url: this.url + '/mobile/realName',
						method:'GET',
						header: {
							'content-type': 'application/x-www-form-urlencoded' ,// 默认值
							'token': this.token
						},
						data:{
							name:this.name,
							zhifu:this.phone,
							// 身份证号码
							IDCardNumber:this.card

						},
						success: (res) => {
							if(res.data.result){
								uni.showToast({
									title:res.data.msg,
									duration:1500,
									success:function(){
										//提交成功
										// uni.navigateBack({
										// 	delta: 1
										// });
										
									}
								})
								if(that.current==1){
									uni.navigateBack({
									   url: '../sellCard/sellCard'
									});
								}
								that.getrealdata() //刷新 显示卡号
							}else{
								uni.showToast({
									title:res.data.msg,
									duration:1500,
								})
							}
						}
					})
				}
			}
		}
	}
</script>

<style>
	.title{
		font-size: 40upx;
		color: #e89439;
		text-align: left;
		font-weight: 550;
		line-height: 100upx;
		padding-left: 20upx;
	}
	.name{
		width: 100%;
		height: 100upx;
		margin-top: 80upx;
		padding: 0 20upx;
		box-sizing: border-box;
	}
	.name .headline,.number .headline{
		width: 27%;
		font-size: 34upx;
		float: left;
		line-height: 100upx;
		margin-right: 10upx;
		display: inline-block;
		text-align-last: justify;
	}
	.name input,.number input{
		width: 67%;
		height: 100upx;
		float: left;
		padding-left: 20upx;
		font-size: 34upx;
		box-sizing: border-box;
		display: inline-block;
	}
	.number{
		width: 100%;
		height: 100upx;
		padding: 0 20upx;
		margin-top: 20upx;
		box-sizing: border-box;
	}
	.btn{
		width: 100%;
		height: 100upx;
		margin-top: 80upx;
		padding: 0 20upx;
		box-sizing: border-box;
	}
	.btn button{
		width: 100%;
		height: 100%;
		background-color: #e89439;
		color: #fff;
	}
	.zh{
		width:100%;
		margin: auto;
		display: flex;
		align-items: center;
	    margin-top: 50upx;
		margin-left:50upx;
	}
	.zh>view{
		width:50%;
		display: flex;
		justify-content: space-between;
		border:1px solid #ccc;
		margin-left:20upx;
	}
</style>
